package dk.com.test;

import java.awt.BorderLayout;
import java.awt.EventQueue;
import java.awt.FlowLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;

import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JList;
import javax.swing.JPanel;
import javax.swing.JTextField;

import org.apache.http.impl.cookie.DateParseException;

import dk.com.dao.BaseDao;
import dk.com.entities.H2ConnectionBuilder;
import dk.com.entities.PersonEntities;
import dk.com.entities.SQLHelper;

public class main {

	private JFrame frmTeamManagement;
	private JTextField textFieldAdaNo;
	private JTextField textFieldPassword;
	private JTextField textField;

	/**
	 * Launch the application.
	 */
	public static void main(String[] args) {
		EventQueue.invokeLater(new Runnable() {
			public void run() {
				try {
					main window = new main();
					window.frmTeamManagement.setVisible(true);
				} catch (Exception e) {
					e.printStackTrace();
				}
			}
		});
	}

	/**
	 * Create the application.
	 */
	public main() {
		initialize();
	}

	/**
	 * Initialize the contents of the frame.
	 */
	private void initialize() {
		frmTeamManagement = new JFrame();
		frmTeamManagement.setTitle("Team Management");
		frmTeamManagement.setBounds(100, 100, 450, 300);
		frmTeamManagement.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		
		JPanel panel = new JPanel();
		frmTeamManagement.getContentPane().add(panel, BorderLayout.NORTH);
		
		JLabel lblAdaNo = new JLabel("ADA");
		panel.add(lblAdaNo);
		
		textFieldAdaNo = new JTextField();
		panel.add(textFieldAdaNo);
		textFieldAdaNo.setColumns(10);
		
		JLabel lblPassword = new JLabel("Password");
		panel.add(lblPassword);
		
		textFieldPassword = new JTextField();
		panel.add(textFieldPassword);
		textFieldPassword.setColumns(10);
		
		JButton btnLogin = new JButton("Login");
		btnLogin.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent arg0) {
				
				BaseDao<PersonEntities> base = new BaseDao<PersonEntities>(PersonEntities.class);
				List<PersonEntities> persons = new ArrayList<PersonEntities>();
				try {
					persons = base.getAll();
				} catch (Exception e) {
					// TODO Auto-generated catch block
					e.printStackTrace();
				} 
				System.out.println(persons);
			}
		});
		panel.add(btnLogin);
		
		JPanel panel_1 = new JPanel();
		frmTeamManagement.getContentPane().add(panel_1, BorderLayout.WEST);
		panel_1.setLayout(new FlowLayout(FlowLayout.CENTER, 5, 5));
		
		textField = new JTextField();
		panel_1.add(textField);
		textField.setColumns(10);
		
		JList list = new JList();
		panel_1.add(list);
	}

}
